<extend name="Layout/application"/>

<block name="css">
   <style>
      .am-form-file {
         position: relative;
         overflow: hidden
      }

      .am-form-file input[type=file] {
         position: absolute;
         left: 0;
         top: 0;
         z-index: 1;
         width: 100%;
         opacity: 0;
         cursor: pointer;
         font-size: 50rem
      }
   </style>
</block>
<block name="content">
   <section class="content-header">
      <h1>
         编辑文章
         <small>Article edit</small>
      </h1>
      <ol class="breadcrumb">
         <li><a href="#"><i class="fa fa-dashboard"></i> Article</a></li>
         <li class="active">Edit</li>
      </ol>
   </section>

   <section class="content" style="width: 70%;">
      <form role="form" method="post" action="{{:url('articles/update',['id'=>$article.id])}}">
         <div class="box-body">
            <div class="form-group">
               <label>文章分类</label>
               <select class="form-control" name="category_id">
                  <option>请选择分类</option>
                  <volist name="categories" id="category">
                     <option value="{{$category.id}}"
                     <eq name="category.id" value="$article.category_id">selected</eq>
                     >{{$category.name}}</option>
                     <volist name="category.children" id="children">
                        <option value="{{$children.id}}"
                        <eq name="children.id" value="$article.category_id">selected</eq>
                        >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+++{{$children.name}}</option>
                     </volist>

                  </volist>
               </select>
            </div>
            <div class="form-group">
               <label>文章标题</label>
               <input type="text" name="title" class="form-control" value="{{$article.title}}">
            </div>
            <div class="form-group">
               <label>关键字</label>
               <input type="text" name="keyword" class="form-control" value="{{$article.keyword}}">
            </div>
            <div class="form-group">
               <label>描述</label>
               <textarea name="description" id="" cols="60" rows="5"
                         class="form-control">{{$article.description}}</textarea>
            </div>
            <div class="form-group">
               <label>缩略图</label>
               <div class="form-group am-form-file">
                  <button class="btn btn-warning"><i class="fa fa-upload" id="loading"></i>上传的缩略图</button>
                  <input type="file" id="image_upload">
                  <input type="hidden" name="photo_id" value="{{$article.photo_id}}">
               </div>
               <div>
                  <img src="{{$article.photo.image}} or http://oze5mdef4.bkt.clouddn.com/cec3f09beaf1f2051ad51277fa2da422.png"
                       id="img_show" style="max-height: 150px;">
               </div>
            </div>
            <div class="form-group">
               <label>排序</label>
               <input type="text" name="sort_order" class="form-control" value="{{$article.sort_order}}">
            </div>
            <div class="form-group">
               <label>是否置顶</label>
               <div class="radio">
                  <label>
                     <input type="radio" name="is_top" value="1"
                     <eq name="article.is_top" value="1">checked</eq>
                     > 是
                  </label>
                  <label>
                     <input type="radio" name="is_top" value="0"
                     <eq name="article.is_top" value="0">checked</eq>
                     > 否
                  </label>
               </div>
            </div>
            <div class="form-group">
               <label>是否推荐</label>
               <div class="radio">
                  <label>
                     <input type="radio" name="is_recommend" value="1"
                     <eq name="article.is_recommend" value="1">checked</eq>
                     > 是
                  </label>
                  <label>
                     <input type="radio" name="is_recommend" value="0"
                     <eq name="article.is_recommend" value="0">checked</eq>
                     > 否
                  </label>
               </div>
            </div>
            <div class="form-group">
               <label>文章内容</label>
               <!-- 加载编辑器的容器 -->
               <textarea id="container" name="content" type="text/plain">{{$article.content}}</textarea>
            </div>


            <div class="box-footer">
               <button type="submit" class="btn btn-primary">提交</button>
               <button type="reset" class="btn btn-default">重置</button>
            </div>
         </div>
      </form>

   </section>
</block>

<block name="js">
   <!--上传图片-->
   <script src="/vendor/qiniu/jquery.html5-fileupload.js"></script>
   <script src="/vendor/qiniu/upload.js"></script>


   <!--ueditor编辑器-->
   <script src="/vendor/ueditor/utf8-php/ueditor.config.js"></script>
   <script src="/vendor/ueditor/utf8-php/ueditor.all.js"></script>
   <script type="text/javascript">
      $(function () {
         //实例化编辑器
         var ue = UE.getEditor('container', {
            initialFrameWidth: 1100,//设置编辑器宽度
            initialFrameHeight: 800,//设置编辑器高度
            scaleEnabled: true,
         });
      })
   </script>

</block>



